<?php

namespace app\model;

use think\Model;

class AbnormalType extends Model
{
    const IS_DELETE_NO = 0;

    const TYPE_BARN = 10;
    const TYPE_FENCE = 11;
    const TYPE_PIG = 12;
    const TYPE_FEED = 20;
    const TYPE_MEDICINE = 21;
    const TYPE_DEVICE = 30;

    /**
     * @Description 判断异常分类是否存在
     * @author: zj
     * @param int $outId
     * @time 2024/03/12 14:42:22
     * @return false|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function checkOutIdIsExist(int $outId)
    {
        $info = $this->field('id')
            ->where('out_id',$outId)
            ->where('delete_time',self::IS_DELETE_NO)
            ->find();
        if (!$info) {
            return false;
        }

        return $info['id'];
    }

    /**
     * @Description 检查异常分类是否存在
     * @author: zj
     * @param string $name
     * @time 2024/03/12 14:43:46
     * @return false|mixed
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function checkNameIsExist(string $name)
    {
        $info = $this->field('id')
            ->where('name',$name)
            ->where('delete_time',self::IS_DELETE_NO)
            ->find();
        if (!$info) {
            return false;
        }

        return $info['id'];
    }

}